package main

func lengthOfLIS(nums []int, k int) int {
	dp := make([]int, len(nums))
	result := 0
	for i := range nums {
		max := 0
		for j := 0; j < i; j++ {
			if nums[i] > nums[j] && nums[i] - nums[j] <= k && dp[j] > max {
				max = dp[j]
			}
		}
		dp[i] = max + 1
		if dp[i] > result {
			result = dp[i]
		}
	}	
	return result
}

func main() {
	res := lengthOfLIS([]int{5,4,7,4,10,17,14}, 7)
	println(res)
}